﻿using Coldairarrow.Business.View;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.View;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.View
{
    [Route("/View/[controller]/[action]")]
    public class View_GetPickUpMainController : BaseApiController
    {
        #region DI

        public View_GetPickUpMainController(IView_GetPickUpMainBusiness view_GetPickUpMainBus)
        {
            _view_GetPickUpMainBus = view_GetPickUpMainBus;
        }

        IView_GetPickUpMainBusiness _view_GetPickUpMainBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<View_GetPickUpMain>> GetDataList(PageInput<GetPickUpMainQueryDTO> input)
        {
            return await _view_GetPickUpMainBus.GetDataListAsync(input);
        }
        [HttpPost]
        public async Task<PageResult<View_PickUpMain>> GetDataListMessageAsync(PageInput<GetPickUpMainQueryDTO> input)
        {
            return await _view_GetPickUpMainBus.GetDataListMessageAsync(input);
        }
        [HttpPost]
        public async Task<View_GetPickUpMain> GetTheData(IdInputDTO input)
        {
            return await _view_GetPickUpMainBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(View_GetPickUpMain data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _view_GetPickUpMainBus.AddDataAsync(data);
            }
            else
            {
                await _view_GetPickUpMainBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _view_GetPickUpMainBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}